<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
</head>
<body>
    <!-- <script type="text/javascript">
        // 1. 函数预编译过程，this指向window
        function test(c) {
            //若 new test()
            //var this = Object.create(test.prototype);
            var a = 123;
            function b() {}
            console.log(this);
        }

        // AO {
        //     arguments: [1],
        //     this: window,
        //     c: 1,
        //     a: undefined,
        //     b: function() {}
        // }
    
        test(1);

    </script> -->

    <script>
        // 2. 全局作用域里，this 指向 window
        console.log(this);

    </script>

    <script>
        // 3. call / apply 可以改变函数运行时this指向

    </script>

    <script>
        // 4. obj.func(); func()里面的this指向obj
        // 谁调用函数，this就指向谁

        var obj = {
            name: 'abc',
            a: function() {
                console.log(this.name);
            }
        }
        obj.a();

    </script>
</body>
</html>